function answerQuestion(answer) {
   var agentName = $("input#agentName").val(); 
   var question = $("input#question").val(); 
    $.ajax({
        url: "functions/ajax/answerQuestion.php",
        context: self,
        type: "post",
        data: {name: agentName,
               question: question,
               answer: answer},
        success: function(data, textStatus, jqXHR) {
            var parsedData = jQuery.parseJSON(data);
            
            var answer = "Oh, that's too bad. I don't like that.";
            if (parsedData.answer) {
                answer = "Oh good! I like that too.";
            }
            $("div#trustText").html('<p>'+answer+'</p> <a href="conversation.php?name='+parsedData.name+'" data-role="button" data-theme="c">Okay</a>');
        }
    });
}

var trustInit;
if (!trustInit) {
    trustInit = true;
    $('#trustDialog').live('pageinit',function(event){
        $("a#yesButton").click(function() {
            answerQuestion("yes");
        });
        $("a#noButton").click(function() {
            answerQuestion("no");
        });
    });
}

